<%--
  Created by IntelliJ IDEA.
  User: LENOVO
  Date: 2023/9/26
  Time: 11:52
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>手机号验证码</title>
    <style>
        body {
            font-family: Arial, Helvetica, sans-serif;
            background-color: #f2f2f2;
        }
        .container {
            max-width: 400px;
            margin: 0 auto;
            padding: 20px;
            background-color: #fff;
            border-radius: 5px;
            box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
        }
        .form-group {
            margin-bottom: 20px;
        }
        label, input[type="tel"], input[type="code"], input[type="submit"] {
            display: block;
            width: 100%;
            padding: 10px;
            border: 1px solid #ccc;
            border-radius: 3px;
        }
        input[type="submit"] {
            background-color: #4CAF50;
            color: #fff;
            cursor: pointer;
        }
        a {
            text-decoration: none;
        }
    </style>
</head>
<body>
<div class="container">
    <h1>根据手机号找回密码</h1>
    <form action="updaphone.jsp">
            <label for="telephone">电话号码：</label>
            <div><input type="tel" id="telephone" name="telephone" required placeholder="请输入手机号">&nbsp;&nbsp;<input type="button" name="send" value="发送短信" onclick="sendCode()"/></div>
        <br>
        <label for="code">短信验证码:</label>
        <div>
            <input type="code" id="code" name="code" placeholder="请输入验证码"/><span id="msgCode"></span>
        </div>
        <br>
            <input type="submit" value="提交">&nbsp;&nbsp;<a href="wjmm.jsp">切换为邮箱验证</a>
    </form>
</div>
</body>
<script src="js/jquery.js"></script>
<script>
    function sendCode() {
        var phoneStr=$("#telephone").val();
        $.ajax({
            url:"${pageContext.request.contextPath}/RLUtilsServlet",
            data:{"phone":phoneStr},
            success:function (data) {
                if (data==0){
                    alert("发送成功!")
                }else {
                    alert("发送失败!")

                }
            }
        })
    }
    $("#code").blur(function () {
        var userCode = $("#code").val();
        $.post("ChePhoneServlet", "code=" + userCode, function (data) {
            if (data == "true") {
                $("#msgCode").html("✔")
                return true;
            } else {
                $("#msgCode").html("✘");
                return false;
            }
        }, "text")
    })
</script>
</html>